const app=getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
      bcolor:'#FF986C',
      list:[]
    },
    jumpPage:function(e){
      let bid=e.currentTarget.id;
      let uid=wx.getStorageSync('Uid')
      console.log(uid)
      wx.navigateTo({
          url:'/pages/me-homepage/me-homepage?Uid='+uid+'&Bid='+bid
      })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      this.getres(); 
    },
    changebtn: function(event){
      var that = this;
      let time=new Date();
      let year = time.getFullYear()
      let month = time.getMonth() + 1
      let date = time.getDate()
      let hours = time.getHours()
      let minute = time.getMinutes()
      let second = time.getSeconds()
      if (month < 10) { month = '0' + month }
      if (date < 10) { date = '0' + date }
      if (hours < 10) { hours = '0' + hours }
      if (minute < 10) { minute = '0' + minute }
      if (second < 10) { second = '0' + second }
      date=year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
      const id=event.currentTarget.dataset.state.Bid;
      const tate=event.currentTarget.dataset.state.Astate;
      console.log(id,tate)
      console.log(time);
      wx.request({
        url:`${app.globalData.url}/message/me-attended`,
        method:'POST',
        data:{
          Bid:id,
          Astate: tate=='+关注'?'已关注':'+关注',
          Time:date,
          Uid:wx.getStorageSync('Uid')
        },
        dataType:'json',
        header:{"Content-Type":"application/x-www-form-urlencoded"},
        success:function(res){
          that.getres();
          console.log(res.data);
            
        },
        fail:function(res){
          console.log(res.message)
        }
      })
      
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
    },
    getres:function(){
      var that = this
      wx.request({
        url:`${app.globalData.url}/message/me-attended?Uid=`+wx.getStorageSync('Uid'),
        success:function(res){
          console.log(res.data)
          that.setData({
            list:res.data
          })
        },
        fail:function(res){
          console.log(res.message)
        }
      })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
      this.getres(); 
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    }
})